using System;
using System.Collections.Generic;
using System.Linq;
using MapComponentSprite;
using MapComponentSprite.Global;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace SanGuo.Component
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class MapComponent : Microsoft.Xna.Framework.DrawableGameComponent
    {
        private MapBackgroundLayerSprite _mainMapLayerSprite;
        private MapBuildingLayerSprite _mapBuildingLayerSprite;
        private SpriteBatch spriteBatch;
        public MapComponent(Game game, SpriteBatch spriteBatch)
            : base(game)
        {
            this.spriteBatch = spriteBatch;
            this._mainMapLayerSprite = MapBackgroundLayerSprite.GetInstance();
            this._mapBuildingLayerSprite=new MapBuildingLayerSprite();
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            this._mainMapLayerSprite.Update(gameTime);
            this._mapBuildingLayerSprite.Update(gameTime);
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            this.spriteBatch.Begin();
            this._mainMapLayerSprite.Draw(gameTime );
            this._mapBuildingLayerSprite.Draw(gameTime );
            this.spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
